Returns the number of days in the specified month. It accounts for leap years
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=short), | intent(in) | :: | month | |||
integer(kind=short), | intent(in) | :: | year |
FUNCTION DaysInMonth & ! (month, year) & ! RESULT (days) IMPLICIT NONE ! Arguments with intent(in): INTEGER (KIND = short), INTENT(IN) :: year, month ! Local variables: INTEGER (KIND = short) :: days !------------end of declaration------------------------------------------------ IF( (month == 1) .OR. (month == 3) .OR. (month == 5) .OR. (month == 7) .OR. & (month == 8) .OR. (month == 10) .OR. (month == 12) ) THEN days = 31 ELSE IF ( (month == 4) .OR. (month == 6) .OR. (month == 9) .OR. & (month == 11) ) THEN days = 30 ELSE IF (month == 2) THEN IF ( IsLeapYear (year) ) THEN days = 29 ELSE days = 28 END IF END IF END FUNCTION DaysInMonth